package schema

import (
	"entgo.io/ent"
	"entgo.io/ent/dialect/entsql"
	"entgo.io/ent/schema"
	"entgo.io/ent/schema/field"
	"entgo.io/ent/schema/index"
	"private-domain-overseas-service/pkg/status/bizsystemappversion"
	"time"
)

type HzSystemAppVersion struct {
	ent.Schema
}

func (HzSystemAppVersion) Fields() []ent.Field {
	return []ent.Field{
		field.String("app_package_name").NotEmpty().Comment("APP应用包名"),
		field.String("app_version").NotEmpty().Comment("APP版本号"),
		field.String("app_version_title").Optional().Comment("标题"),
		field.Int64("app_platform").Comment("APP平台，1、安卓，2、ios"),
		field.Int64("app_force_update_type").Default(bizsystemappversion.Unforce).Comment("APP强制更新类型：1、不强制，2、强制"),
		field.Int64("app_hot_update_type").Default(bizsystemappversion.Update).Comment("APP热更新类型:1、热更新，2、不热更新"),
		field.Int64("app_publish_status").Default(bizsystemappversion.Publish).Comment("APP发布状态,1、已发布，2、待发布，3、已下架"),
		field.Int64("app_sdk_update_type").Default(bizsystemappversion.Wgt).Comment("AppSDK更新类型:1、wgt，2、apk"),
		field.String("app_update_download_url").Optional().Comment("APP更新下载地址"),
		field.Text("app_version_description").Optional().Comment("APP版本详情（应用名称-版本描述）"),
		field.Int64("created_at").Immutable().Default(time.Now().Unix()).Comment("创建时间"),
		field.Int64("update_at").Default(time.Now().Unix()).Comment("更新时间"),
		field.Int64("delete_at").Optional().Comment("删除时间"),
	}
}

func (HzSystemAppVersion) Indexes() []ent.Index {
	return []ent.Index{
		index.Fields("app_package_name"),
		index.Fields("app_version"),
	}
}

func (HzSystemAppVersion) Annotations() []schema.Annotation {
	return []schema.Annotation{
		entsql.WithComments(true),
		schema.Comment("系统版本表"),
	}
}
